<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="fck" uri="/WEB-INF/FCKeditor.tld"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="com.fredck.FCKeditor.FCKeditor"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="<%=request.getContextPath() %>/css/Style.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="<%=request.getContextPath() %>/FCKeditor/fckeditor.js"></script>
<title>增加产品</title>
<script type="text/javascript">
	var tt_array = new Array();
	tt_array[0]="congye";
	tt_array[1]="zhuanchang";
	tt_array[2]="jianli";
	tt_array[3]="linian";
	tt_array[4]="zuopin";
	tt_array[5]="zhiwei";
	var tmp_title ="";	
	function checkImage(){
			var img = document.getElementById("uploadimg").value;
			if(img.length<3){
				alert("只能上传 .BMP .JPG .JPEG .PNG .GIF 文件！");
				document.getElementById("sub_btn").disabled=true;
				return;
			}
			var regex=  /\.jpg$|\.jpeg$|\.gif$|\.png$/i;
			var len = img.lastIndexOf(".");
			img = img.substring(len).toLowerCase();
			if(!regex.test(img)){
				alert("只能上传 .BMP .JPG .JPEG .PNG .GIF 文件！");
				document.getElementById("sub_btn").disabled=true;
				return;
			}else{
				document.getElementById("sub_btn").disabled=false;
			}
		}
	function checkSubmit(){
	var mark = document.getElementById("title").value;
	var content = document.getElementById("image.elseContent").value;		
	var img = document.getElementById("uploadimg").value;
		if(mark==''){
				alert("你还没有填写图片说明！");
				return;
			}
		if (img.length < 3) {
			alert("只能上传 .BMP .JPG .JPEG .PNG .GIF 文件！");
			return;
		}
		var regex = /\.jpg$|\.jpeg$|\.gif$|\.png$/i;
		var len = img.lastIndexOf(".");
		img = img.substring(len).toLowerCase();
		if (!regex.test(img)) {
			alert("只能上传 .BMP .JPG .JPEG .PNG .GIF 文件！");
			return;
		} else {
			document.getElementById("c_from").submit();
		}
	}

	function checkSubmit1(){
			var title = document.getElementById("title").value;
			var t = document.getElementById("type").value;
			if("designer"==t){
				var t_string = "{";
				for(var i = 0 ;i<tt_array.length;i++){
						var tt_string =document.getElementById(tt_array[i]+"").value;
						t_string+="\""+tt_array[i]+"\":" +"\""+tt_string+"\""+",";
				}
				t_string = t_string.substring(0, t_string.length-1);
				t_string += "}";
				document.getElementById("reMark").value = t_string;
				}else if("case"==t){
						var biaoqian = document.getElementById("biaoqian").value;
						if(biaoqian.length<1){
								alert("请填写标签分类！");
								return;	
							}
						var f_string ='{"fenlei":"'+biaoqian+'"}';
						document.getElementById("reMark").value = f_string;
					}
			
			var elseContent = document.getElementById("image.elseContent").value;
			if(title.length<1){
					alert("请填写"+tmp_title+"!");
					return;
				}
			if(elseContent.length<1){
					alert("请填写说明");
					return;
				}
			document.getElementById("c_from").submit();
		}
</script>
</head>
<body>
	<table border="0" cellspacing="0" cellpadding="0" class="thead" width="100%">
	<tr><td style="padding:3px;">当前位置:编辑图片</td></tr>
</table>
<form action="<%=request.getContextPath() %>/admin/updateImage.htm" method="post" id="c_from" enctype="multipart/form-data">
	<input type="hidden" name="image.type" id="type" value="${image.type}"/>
	<input type="hidden" name="image.id" value="${image.id}"/>
	<input type="hidden" name="image.path" value="${image.path}"/>
	<input type="hidden" name="image.reMark" id="reMark" value='<s:property value="image.reMark"/>'/>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
	<tr>
		<td width="10%">&nbsp;</td>
		<td>
		<table cellspacing="0" cellpadding="0" border="1"  class="Table1" align="center" width="100%">
			<tbody>
				<tr>
					<td></td>
					<td id="errormsg"><s:fielderror/><s:actionerror/> </td>
				</tr>
				<tr>
					<td height="25" align="right" width="20%">图片<span style="color:red;">*</span>：</td>
					<td width="80%"><img alt="" src="<%=request.getContextPath() %>/<s:property value='image.path'/>" /> </td>
				</tr>
				<tr>
					<td height="25" align="right"><span id="whattype">标题</span><span style="color:red;">*</span>：</td>
					
					<td><input type="text" name="image.title" maxlength="40" id="title" value="<s:property value='image.title'/>" /></td>
				</tr>
				<tr id="congye_tr" style="display: none">
					<td height="25" align="right" width="20%">从业年限：</td>
					<td ><input type="text"  id="congye" /></td>
				</tr>
				<tr id="zhiwei_tr" style="display: none">
					<td height="25" align="right" width="20%">职位：</td>
					<td ><input type="text"  id="zhiwei" /></td>
				</tr>
				<tr id="zhuanchang_tr" style="display: none">
					<td height="25" align="right" width="20%">个人专长：</td>
					<td ><input type="text"  id="zhuanchang" /></td>
				</tr>
				<tr id="jianli_tr" style="display: none">
					<td height="25" align="right" width="20%">个人简历：</td>
					<td ><input type="text"  id="jianli" /></td>
				</tr>
				<tr id="linian_tr" style="display: none">
					<td height="25" align="right" width="20%">设计理念：</td>
					<td ><input type="text"  id="linian" /></td>
				</tr>
				<tr id="zuopin_tr" style="display: none">
					<td height="25" align="right" width="20%">楼盘作品：</td>
					<td><input type="text"  id="zuopin" /></td>
				</tr>
				<tr id="name_tr" style="display: none">
					<td height="25" align="right" width="20%" ><span id="name_tip">显示位置</span>：</td>
					<td ><input type="text" name="image.name"  id="name" maxlength="4" value="${image.name}"/>&nbsp;&nbsp;<span id="tip">此处填入数字，数字越大，显示越靠前</span></td>
				</tr>
				<tr id="biaoqian_tr" style="display: none">
					<td height="25" align="right" width="20%">标签分类：</td>
					<td><input type="text"  id="biaoqian" /></td>
				</tr>
				<tr style="display:none">
					<td>
						<script type="text/javascript">
						var t = document.getElementById("type").value;
						if(t=="designer"){
							var temp = ${image.reMark};
							temp = eval(temp);
							tt_array[0]="congye";
							tt_array[1]="zhuanchang";
							tt_array[2]="jianli";
							tt_array[3]="linian";
							tt_array[4]="zuopin";
							tt_array[5]="zhiwei";
							document.getElementById("congye").value=temp.congye;
							document.getElementById("congye_tr").style.display="";
	
							document.getElementById("zhuanchang").value=temp.zhuanchang;
							document.getElementById("zhuanchang_tr").style.display="";
	
							document.getElementById("jianli").value=temp.jianli;
							document.getElementById("jianli_tr").style.display="";
	
							document.getElementById("linian").value=temp.linian;
							document.getElementById("linian_tr").style.display="";
	
							document.getElementById("zuopin").value=temp.zuopin;
							document.getElementById("zuopin_tr").style.display="";
	
							document.getElementById("zhiwei").value=temp.zhiwei;
							document.getElementById("zhiwei_tr").style.display="";

							document.getElementById("name_tr").style.display="";
						}else if(t=="case"){
							 var temp = ${image.reMark};
							document.getElementById("biaoqian_tr").style.display="";
							document.getElementById("biaoqian").value = temp.fenlei;
							
							document.getElementById("name_tr").style.display="";
							document.getElementById("tip").innerHTML="输入任意值该案例将在首页展示，不输入则不会显示在首页";
							document.getElementById("name_tip").innerHTML="是否显示在首页";
							}
						
					</script>
					</td>
				</tr>
				<tr>
					<td height="25" align="right">说明<span style="color:red;">*</span>：</td>
					<td>
						<!-- textarea name="image.elseContent" id="image.elseContent"><s:property value="image.elseContent" escape="false"/></textarea-->
						<fck:editor id="image.elseContent" height="300" width="100%">
							<s:property value="image.elseContent" escape="false"/>
						</fck:editor>
					</td>
				</tr>
				<tr>
					<td height="25" align="right" style="display: none"></td>
					<td height="25" align="right" style="display: none"></td>
				</tr>
				<tr>
					<td height="25" colspan="2" align="center">
					<input type="button" onclick="checkSubmit1();" value="确定" id="sub_btn" />
					<s:if test="method=='success'">
					<input type="button" onclick="window.location.href='<%=request.getContextPath() %>/admin/getSomeImage.htm?nodeid=${nodeid}&type=${type}'" value="返回查看"  />
					</s:if>
					</td>
				</tr>
			</tbody>
		</table>
		</td>
		<td width="10%">&nbsp;</td>
	</tr>
</table>
</form>
</body>
<script type="text/javascript">
	window.onload = function() {
		var t = document.getElementById("type").value;
		var tt = document.getElementById("whattype");
		if(t=="designer"){
			tmp_title ="设计师";
			}
		else{
			tmp_title ="标题";
			}
		tt.innerHTML =tmp_title;
		//var sBasePath = document.location.href.substring(0,document.location.href.lastIndexOf('_samples'));
		//var oFCKeditor = new FCKeditor('image.elseContent');
		//oFCKeditor.Width = '500';
		//oFCKeditor.Height = '300';
		//oFCKeditor.BasePath = "<%=request.getContextPath()%>/FCKeditor/";
		//oFCKeditor.ReplaceTextarea();
	};
</script>
</html>